<?php
class Users_acl
{
	function __construct($permissions_granted_array = null) //basically then this class has been initiated, set the page permissions
	{
		if(is_array($permissions_granted_array))
		{
			//check to see if the user accesslevel is in that array
			//print_r($permissions_granted_array);
			if(!in_array($_SESSION['login_admin_permission_level'], $permissions_granted_array))
			{
				// Access forbidden:
				header('HTTP/1.1 401 Unauthorized');
					header("location: /errors/403");
					exit;
			}
		}
		else
		{
			//no page permissions set so carry on as normally really
		}
	}

	//can be used for if/else statements to see if the user falls within the required permission
	//returns true or false.
	static function Is_user_authorized($permissions_granted_array = null)
	{
		if(is_array($permissions_granted_array))
		{
			//check to see if the user accesslevel is in that array
			//print_r($permissions_granted_array);
			if(in_array($_SESSION['login_admin_permission_level'], $permissions_granted_array))
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}
}
?>